﻿using System;
using MDK.Device.Components;

namespace MDK.Device.Devices
{
    public class Back2Device
    {
        public Back2Device(IPlcDevice device)
        {
            Device = device;
            InitializeComponents();
        }
        public IPlcDevice Device { get; }
        public IAxle X { get; private set; }
        public IAxle Y { get; private set; }
        public IAxle SZ { get; private set; }
        public ISwitch Lamp { get; private set; }
        public ISwitch UVLamp { get; private set; }
        public ISwitch Finger { get; private set; }
        public ISensor[] CarrierSensors { get; private set; }
        public IRotator FingerRotator { get; private set; }
        public ISensor FingerCheckSensor { get; private set; }
        private void InitializeComponents()
        {
            CarrierSensors = new ISensor[]
            {
                new Sensor(Device, "X26"), new Sensor(Device, "X27"), new Sensor(Device, "X30"), new Sensor(Device, "X31"), new Sensor(Device, "X32"), new Sensor(Device, "X33"), new Sensor(Device, "X34"), new Sensor(Device, "X35"),
                new Sensor(Device, "X36")
            };

            X = new StdAxle(Device, "DD34", "DD100", "L0", "M30", "M358", "M20", "M21", "DD36", "M350", "M356", "D7", "X21", "X22", "X20","M359");
            Y = new StdAxle(Device, "DD38", "DD102", "L1", "M32", "M362", "M22", "M23", "DD40", "M352", "M360", "D10", "X24", "X23", "X25","M363");
            SZ = new LocationAxle(Device, new PlcAddress[] {"M26", "M27", "M28"}, "D18", "M36", "M29", "X7", "X4") ;
            Finger = new DoubleBitSwitch(Device, "M69", "M70");Lamp = new Switch(Device, "M175");
            UVLamp = new Switch(Device, "M174");
            FingerRotator = new Rotator(Device, "M54", "M45", "DD1004", "M147", "M157", "DD1002", "M171", "M172", "M63");
            FingerCheckSensor = new Sensor(Device, "X100");
        }
    }
}